#ifndef _BASE
#define _BASE

// INCLUDES --------------------------------------------------------------------------
#include "stdbool.h"
#include "string.h"
#include "stdio.h"
#include "math.h"

// DEFINES ---------------------------------------------------------------------------
#define DEBUG

#ifdef DEBUG

	// sanity check(s) for various errors

  // ------------------------------------------------------------------
  /* f   -> function name as string
     p   -> pointer to check
     ... -> alternative return value */
  #define GUARD_NULL(f, p, ...) \
  { \
    if (p == NULL) { \
      printf( "NULL pointer as target! [%s->%s:%d]\n", f, __FILE__, __LINE__ ); \
      return __VA_ARGS__; \
    } \
  }

  /* f   -> function name as string
     k   -> value to check
     ... -> alternative return value */
  #define GUARD_ZERO(f, k, ...) \
  { \
    if (k == 0) { \
      printf( "division by zero! [%s->%s:%d]\n", f, __FILE__, __LINE__ ); \
      return __VA_ARGS__; \
    } \
  }

	/* msg -> message string to print
	   ... -> alternative string variables */
	#define PRINT(msg, ...) \
	{ \
		printf(msg, ##__VA_ARGS__); \
	};
  // ------------------------------------------------------------------

#else

  // no performance penalty here...

  // ------------------------------------------------------------------
  #define GUARD_NULL(f, p, ...) { return __VA_ARGS__ };
  #define GUARD_ZERO(f, k, ...) { return __VA_ARGS__ };

	#define PRINT(msg, ...) {};
  // ------------------------------------------------------------------

#endif // DEBUG

// TYPEDEFS --------------------------------------------------------------------------

// float
typedef float              fp32;
typedef double             fp64;

// byte
typedef char               b8;
typedef unsigned char      ub8;

// single
typedef short              i16;
typedef unsigned short     ui16;

// int
typedef int                i32;
typedef unsigned int       ui32;

// long
typedef long               i64;
typedef unsigned long      ui64;

// long long
typedef long long          i128;
typedef unsigned long long ui128;

#endif // _BASE
